package marmalius.command;

import marmalius.Player;

public abstract class BaseCommand {
	protected int security;
	protected String help;
	
	public abstract void process(Player player, String[] command);
	
	public BaseCommand() {
		security = -1;
		help = null;
	}
	
	public void setHelp(String help) { this.help = help; }
	public void setSecurity(int security) { this.security = security; }
	public boolean haveAccess(int level) {
		return security != -1 && level >= security;
	}
	
	protected void showHelp(Player player) {
		if (help != null)
			player.sendPlayerMessage(help);
	}
	
	protected int ParseInteger (String data) {
    	try {
    		return Integer.parseInt(data);
    	}
    	catch (NumberFormatException e) {
    		return 0;
    	}
    }
}
